<!DOCTYPE html>
<html  xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta content="telephone=no" name="format-detection">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1;user-scalable=no;">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>购物车</title>
    <link rel="stylesheet" href="/statics/view/css/bootstrap.css">
    <link rel="stylesheet" href="/statics/view/css/style.css">
    <link rel="stylesheet" href="/statics/view/css/member.css">
    <link rel="stylesheet" href="/statics/view/css/order3.css">
    <script charset="utf-8" src="/statics/view/js/jquery.min.js"></script>
    <script charset="utf-8" src="/statics/view/js/global.js"></script>
    <script charset="utf-8" src="/statics/view/js/bootstrap.min.js"></script>
    <script charset="utf-8" src="/statics/view/js/template.js"></script>
</head>

<body>
<div class="fanhui_cou">
    <div class="fanhui_1"></div>
    <div class="fanhui_ding">顶部</div>
</div> <header class="header header_1">
    <div class="fix_nav">
        <div style="max-width:768px;margin:0 auto;background:#db3652;position: relative;">
            <a class="nav-left back-icon" href="javascript:history.back();">返回</a>
            <div class="tit">购买清单</div>
            <a class="nav-right icon-home" href="/dbs/index.html">首页</a>
        </div>
    </div>
</header>
<form action="/db/order/submit" method="POST">
<div class="container ">

    <div class="row rowcar">
        <ul class="list-group">

            <li class="list-group-item hproduct clearfix">
                <input type="hidden" name="singleAmount"  value="${dbTimes.singleAmount}"/>
                <input type="hidden" name="productId"  value="${dbProduct.id}"/>
                <input type="hidden" name="timesNo"  value="${dbTimes.timesNo}"/>
                <input type="hidden" name="purchaseQuantity"  value="${dbTimes.purchaseQuantity}"/>
                <div class="p-pic"><a href="/db/product-${dbProduct.id}-${dbTimes.timeNo}"><img class="img-responsive" src="${dbProduct.thumbnail}" alt="${dbProduct.name}"></a></div>
                <div class="p-info">
                    <a href="/db/product-${dbProduct.id}-${dbTimes.timeNo}"><p class="p-title">${dbProduct.name}</p></a>
                    <p class="p-attr">
                        <span>总需 ${dbTimes.quantity} 人次</span><span>剩余 <em class="red">${dbTimes.quantity-dbTimes.currentQuantity}</em>人次</span></p>
                    <p class="p-origin">
                        <a class="close p-close" href="javascript:void(0);" data-pro="del">×</a>
                    </p>
                </div>
            </li>
            <li class="list-group-item clearfix">

                <div class="btn-group btn-group-sm control-num">
                    <a class="btn btn-default" data-action="moveNum" data-pro="minus"  href="javascript:void(0);"><span class="glyphicon glyphicon-minus gary"></span></a>
                    <input type="num" class="btn gary2 Amount" name="num" data-pro="input" value="${num}" maxlength="5"  pattern="[0-9]*">
                    <a class="btn btn-default" data-action="addNum" data-pro="plus"  href="javascript:void(0);"><span class="glyphicon glyphicon-plus gary"></span></a>
                </div>
            </li>
        </ul>

    </div>

</div>
<div class="fixed-foot">
    <div class="fixed_inner">
        <div class="pay-point" id="pro-view-4">
            <p>共参与1件商品，总计：<em class="red f22">¥<span id="cart_amount">${dbTimes.singleAmount*num}</span></em></p>
        </div>
        <div class="buy-btn-fix">
            <button type="submit" class="btn btn-danger btn-buy">去支付</button>
        </div>
    </div>
</div>
</form>
<div class="clear"></div>

<footer class="footer">

</footer><script type="text/javascript">
    $(function(){
        var singleAmount=parseFloat($("input[name='singleAmount']").val());
        var purchaseQuantity=parseFloat($("input[name='purchaseQuantity']").val())
        var stepNum=parseInt('${dbTimes.stepNum}');
        $("a[data-action='moveNum']").click(function(){
            var currentNum=$("input[name='num']").val();
            var num=parseInt(currentNum);
            if(num==stepNum){
                alert("不能再减少");
                return;
            }
            $("input[name='num']").val(num-stepNum);
            $("#cart_amount").html((num-stepNum)*singleAmount);
        });
        $("a[data-action='addNum']").click(function(){

            var currentNum=$("input[name='num']").val();
            var num=parseInt(currentNum);
            if(num+stepNum>purchaseQuantity){
                alert("单用户最大限制为:"+purchaseQuantity+"份");
                return;
            }
            $("input[name='num']").val(num+stepNum);
            $("#cart_amount").html((num+stepNum)*singleAmount);
        });

        $("input[name='num']").change(function(){
            var current=$("input[name='num']").val();
            if(current%stepNum!=0){
                alert("必须是:"+stepNum+"的整数倍");
                $("input[name='num']").val(stepNum);
                current=stepNum;
            }
            if(current>purchaseQuantity){
                alert("单用户最大限制为:"+purchaseQuantity+"份");
                current=purchaseQuantity;
                $("input[name='num']").val(purchaseQuantity);
            }
            $("#cart_amount").html(current*singleAmount);
        });
    });
</script>
</body></html>
